clear all;
display('------------------------')
% Set Parameters
order_start = 1;
order_finish = 8; % num of iterations
mapDimension = 2^order_start+1;
h = 0.8; % Smoothness factor 0 to 1. 0 = max. roughness. 0.9 = natural  
cell_types = struct('name',{{'Cell Type 3','Cell Type 2','Cell Type 1'}},'value',[6 50 175]); % must be entered monotonically
map = zeros(2^order_start+1)+inf;
map(1,1)=0; map(1,mapDimension)=0; map(mapDimension,1)=0; map(mapDimension,mapDimension)=0;

% Seeding
seed_center = 100;
map((2^order_start)/2 + 1,(2^order_start)/2 + 1 ) = seed_center;

for loop = order_start:order_finish % iterates 
    
    display({'Loop = ',loop})
	mapDimension = 2^loop +1;
    initialVariance = floor(mapDimension/2); % mapDimension/2 creates natural mages
	if ~exist('map')
		map=createFractalTerrain(mapDimension,initialVariance,h); 
	else
		map=createFractalTerrain(mapDimension,initialVariance,h,map);
	end

	plotMatrix3d(map);  
    set(gca,'view',[0 90])
%     h = colorbar;
%     set(h,'ytick',[-100 0 100]);
%     set(h,'yticklabel',{'pyramidal','stellate','glial'})
% 
% 	axis equal;
       
	if loop ~= order_finish
  		map=growMatrix(map,loop+1);
        pause;
	end;
end
